home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
443_01
/
doc
/
info
/
cncl.info-5
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
GNU Info File
|
1996-01-04
|
47.2 KB
|
1,648 lines
This is Info file cncl.info, produced by Makeinfo-1.63 from the input
file cncl.texi.
This file documents the use of CNCL, the Communication Networks Class
Library.
Copyright (C) 1993-1996, Communication Networks.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into other languages, under the above conditions for modified
versions.
File: cncl.info, Node: CNString, Next: CNNamed, Prev: CNICoord, Up: Misc
CNString -- Character String
============================
SYNOPSIS
--------
`#include <CNCL/String.h>'
TYPE
----
`CN_STRING'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNNamed:: CNObject with Name
DESCRIPTION
-----------
`CNString' is a dynamic string manipulating class. Each `CNString'
manages the string itself (stored as a normal C character string), the
length of the string, and the allocated space. The characters are
indexed from 0 to length-1.
Constructors:
`CNString();'
`CNString(int extra);'
`CNString(char c);'
`CNString(char c, int extra);'
`CNString(const char* cs);'
`CNString(const char* cs, int extra);'
`CNString(const CNString& s);'
`CNString(const CNString& s, int extra);'
`CNString(CNParam *param);'
Initializes the CNString. The `extra' parameter gives a hint as to
how many extra characters one expects the string to grow. Its
default value is 10.
Destructors:
`~CNString();'
Deletes the CNString.
In addition to the member functions required by CNCL, `CNString'
provides:
`default_extra = 10;'
Default amount of additional storage allocated. Actually set to 10.
`void resize(unsigned i);'
Changes the capacity of the string either to its length plus
default_extra or to i, whichever is longer.
`void to_lower();'
Converts all characters in this string to lowercase.
`void to_upper();'
Converts all characters in this string to uppercase.
`void capitalize();'
Converts each first character of a word to uppercase, all other
characters to lowercase. A new word is either at the beginning of
the string or it starts with a space (e.g. "a.R fd" will be
capitalized to "A.r Fd").
`void strip_crlf();'
Removes '\r' and/or '\n' at end of string.
`void strip_lspace();'
`void strip_rspace();'
`void strip_space();'
Removes the left, the right or all white spaces of the string.
`unsigned capacity() const;'
Returns the amount of space allocated to this string.
`unsigned length() const;'
Returns the length of this string.
`CNString after(unsigned pos, unsigned l = 0) const;'
Returns the l characters of this string after position pos
(zero-based) as a string. The character at pos will be the first
character of the new string. The default value l = 0 will return
all characters after pos.
`CNString before(unsigned pos, unsigned l = 0) const;'
Returns the l characters of this string before position pos (zero
based) as a string. The character at pos will be the last
character of the new string. The default value l = 0 will return
all characters before pos.
`CNString& add(char c);'
`CNString& add(const char* cs);'
Adds the character c or the character string cs to the end of this
string. If this string does not have enough space allocated it
will be changed automatically.
`CNString& del(unsigned pos = 0, unsigned l = 1);'
Deletes l characters beginning at position `pos' (zero based).
Default values are pos = 0 and l = 1 (e.g. a.del() will delete the
first character of string a). If l is set to 0 all characters
beginning at pos will be deleted (e.g. a.del(0,0) will delete all
characters in string a). Negative `pos' values count from end of
string.
`CNString& del(char c, int pos = 0);'
`CNString& del(const char* cs, int pos = 0);'
`CNString& del(const CNString& s, int pos = 0);'
Deletes character c, character string cs or string s at its first
occurence in this string after position pos (zero based, default
value pos = 0). It deletes nothing if c, cs or s is not in.
`CNString& insert(char c, int pos = 0);'
`CNString& insert(const char* cs, int pos =0);'
`CNString& insert(const CNString& s, int pos = 0);'
Inserts character c, character string cs or CNString s at position
pos (zero based, default value pos = 0).
`CNString& replace(char c, int pos = 0);'
Replaces the character at position pos (zero based, default value
pos = 0) with the character c.
`CNString& replace(const CNString& s, int pos = 0, int l = 0);'
Replaces the l characters starting at position pos (zero based,
default value pos = 0) with the characters of string s. Default
value l = 0 will replace as many characters as s.length(). The
capacity is changed to the needed space plus the default extra
value.
`CNString& replace(char oldc, char newc, int pos = 0);'
Replaces character oldc at its first occurence after position pos
(zero based, default value pos = 0) with newc. If oldc is not in
this string after pos nothing will be changed.
`CNString& replace(const CNString& olds, const CNString& news, int pos = 0);'
Replaces string olds at its first occurence after position pos
(zero based, default value pos = 0) with string news. If olds is
not in this string nothing will be changed.
`int downsearch(char c, int pos = 0);'
`int downsearch(const CNString& s, int pos = 0);'
`int downsearch(const char *cs, int pos = 0);'
Returns the last occurence of character c or string s in this
string before position pos (zero based, default value pos = 0) or
the end of this string if pos = 0 or pos >= len. If c or s is not
in this string before pos len is returned.
`int upsearch(char c, int pos = 0);'
`int upsearch(const CNString& s, int pos = 0);'
`int upsearch(const char *s, int pos=0) const;'
Returns the first occurence of character c or string s in this
string after position pos (zero based, default value pos = 0).
Returns len if c or s is not in this string after pos.
`bool matches(const char* cs, unsigned pos = 0);'
`bool matches(const CNString& s, unsigned pos = 0);'
Returns TRUE if the character string cs or the string s is equal
to the part of this string starting at position pos (zero based,
default value pos = 0).
`operator const char * () const;'
Returns the the C string component of `CNString' to allow the use
of `CNString's in a `char *' context.
`char operator ()(int i) const;'
`char &operator [](int i);'
Returns the i-th character (zero based) of this string.
`void operator = (const CNString& s);'
`void operator = (const char* cs);'
`void operator = (char c);'
Replaces this string with a copy of string s, character string cs
or character c.
`friend CNString operator + (const CNString& a, const CNString& b);'
Returns a string that is the concatenation of the strings `a' and
`b'.
`CNString& operator +=(const CNString &s);'
`CNString& operator +=(const char* cs);'
Appends the C string `s' or the `CNString' `cs' to the end of this
string.
`friend bool operator < (const CNString& a, const CNString& b);'
`friend bool operator > (const CNString& a, const CNString& b);'
`friend bool operator >= (const CNString& a, const CNString& b);'
`friend bool operator <= (const CNString& a, const CNString& b);'
`friend bool operator == (const CNString& a, const CNString& b);'
`friend bool operator != (const CNString& a, const CNString& b);'
Returns `TRUE' if the relation holds between the strings.
`void icopy(istream& strm = cin);'
`istream &operator >> (istream& strm, CNString& s);'
Reads all characters up to (not including) the next newline from
input stream strm into the string.
For programming convenience, a type for a `const' reference to a
string is provided:
`typedef const CNString & CNStringR;'
File: cncl.info, Node: CNNamed, Next: CNIniFile, Prev: CNString, Up: Misc
CNNamed -- CNObject with Name
=============================
SYNOPSIS
--------
`#include <CNCL/Named.h>'
TYPE
----
`CN_NAMED'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNString:: Character String
DESCRIPTION
-----------
`CNNamed' is a data type for managing CNObject's names in CNString
format.
Constructors:
`CNNamed();'
`CNNamed(CNStringR name);'
Initializes the string name object and optionally sets the name.
In addition to the member functions required by CNCL, `CNNamed'
provides:
`CNStringR name() const;'
`CNStringR get_name() const;'
Returns the object's name.
`void name(CNStringR name) const;'
`void set_name(CNStringR name) const;'
Sets the object's name.
File: cncl.info, Node: CNIniFile, Next: CNFormInt, Prev: CNNamed, Up: Misc
CNIniFile -- .ini-style config file
===================================
SYNOPSIS
--------
`#include <CNCL/IniFile.h>'
TYPE
----
`CN_INIFILE'
* Menu:
BASE CLASSES
------------
* CNNamed:: CNObject with Name
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
DESCRIPTION
-----------
The class `CNIniFile' reads/writes MSDOS-style .INI files.
Example of a .INI file:
# This is a comment
[Test]
display = 1
string = Hallo!
abc
In this example the variables display, string and abc of section Test
are declared. At this class each single line is handled as a node of a
double linked list. Each node has a left entry (variable), a right one
(value) and a type entry (COMM, EMPTY, SECTION, ENTRY, ENTRYNOEQ).
Depending on the different types, left and/or right entry can be empty.
Attention : This class is still under construction ! !
Constructors:
`CNIniFile();'
`CNIniFile(CNParam *);'
`CNIniFile(CNStringR name);'
Initializes the `CNIniFile'. The `name' parameter will
automatically read the file `name'.INI into double linked list.
In addition to the member functions required by CNCL, `CNIniFile'
provides:
`int read()'
`int read(CNStringR name);'
Reads the specified .ini file. Either the object's name or the
`name' parameter is chosen. The whole file is stored as a double
linked list.
`int write();'
`int write(CNStringR name);'
Writes the current list into a .ini file.
`CNStringR get_entry(CNStringR section, CNStringR name, bool first=TRUE);'
NOT IMPLEMENTED YET.
`CNStringR get_entry(CNStringR name, bool first=TRUE);'
Returns the entry for `name' as a string.
`double get_double(CNStringR section, CNStringR name, bool first=TRUE);'
NOT IMPLEMENTED YET.
`double get_double(CNStringR name, bool first=TRUE);'
Returns the entry for `name' as a double.
`int get_int(CNStringR section, CNStringR name, bool first=TRUE);'
NOT IMPLEMENTED YET.
`int get_int(CNStringR name, bool first=TRUE);'
Returns the entry for `name' as an integer.
`bool test_entry(CNStringR section, CNStringR name);'
NOT IMPLEMENTED YET.
`bool test_entry(CNStringR name, bool first=TRUE);'
NOT IMPLEMENTED YET.
`CNStringR get_section();'
Returns the sections's name.
`void set_section(CNStringR section);'
Sets the internal `CNDLIterator' `ini_sec' to the begining of the
section called `name'
File: cncl.info, Node: CNFormInt, Next: CNFormFloat, Prev: CNIniFile, Up: Misc
CNFormInt -- Integers as CNStrings
==================================
SYNOPSIS
--------
`#include <CNCL/FormInt.h>'
TYPE
----
`CN_FORMINT'
* Menu:
BASE CLASSES
------------
* CNString:: Character string
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNFormFloat:: Doubles as CNStrings
DESCRIPTION
-----------
This class converts Integers to Strings using different kinds of
format styles provided by the stream-2.0-implementation. The current
formats implemented in this class are 'left' and 'right'. Note: If the
Integer needs more characters than the width `w' indicates, the most
right ones are ignored.
Constructors:
`CNFormInt();'
`CNFormInt(CNParam *param);'
`CNFormInt(int a, int w);'
`CNFormInt(int a, int w, char fill);'
`CNFormInt(int a, int w, char fill, int f);'
Initializes `CNFormInt', setting the value to the integer value a
(default = 0), the string's width, the fill character fill
(default = ' ') and the format f (default = CNFormInt::right)
The different formats implemented in `CNFormInt' are:
`int right = 1'
`int left = 2'
In addition to the member functions required by CNCL, `CNFormInt'
provides:
`int get_value();'
`int value();'
Returns the value as an integer.
`void set_value(int a);'
`void value(int a);'
Changes the old String and the old value to a.
`char get_fill();'
`char fill();'
Returns the current fill character.
`void set_fill(char f);'
`void fill(char f);'
Changes the String to the fill character f.
`int get_format();'
`int format();'
Returns the current format as an integer. '1' descibes 'right', '2'
describes left.
`void set_format(int f);'
`void format(int f);'
Changes the String to the new CNFormInt::formats f.
`int get_width();'
`int width();'
Returns the String's width as an integer.
`void set_width(int w);'
`void width(int w);'
Changes the old String's width to w.
File: cncl.info, Node: CNFormFloat, Next: CNInt, Prev: CNFormInt, Up: Misc
CNFormFloat -- Doubles as CNStrings
===================================
SYNOPSIS
--------
`#include <CNCL/FormFloat.h>'
TYPE
----
`CN_FORMFLOAT'
* Menu:
BASE CLASSES
------------
* CNString:: Character strings
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNFormInt:: Integer as CNStrings
DESCRIPTION
-----------
This class converts doubles to CNStrings using different kinds of
format styles provided by the stream-2.0-implementation. The current
formats implemented in this class are 'left' and 'right' in connection
with 'scientific', 'showpoint' or 'fixed'. Note: If the number is too
long, the right part of it will be cut, no matter wich format style is
chosen. If the number is cut (because of the chosen precision) it will
be round. If the precision is not in the interval [0,16] problems with
the accuracy might occur.
Constructors:
`CNFormFloat();'
`CNFormFloat(CNParam *param);'
`CNFormFloat(double x, int w);'
`CNFormFloat(double x, int w, char fill);'
`CNFormFloat(double x, int w, char fill, int format);'
`CNFormFloat(double x, int w, char fill, int format, int pr);'
Initializes the `FormFloat' with the value x (default = 0.0), the
width w (= 3), the fill character fill (= ' '), the format (=
right) and the precision pr (= 6).
The different formats implemented in `CNFormFloat' are:
`int right = 1'
`int left = 2'
`int scientific = 4'
`int showpoint = 8'
`int fixed = 16'
These formats can be devided into two groups: right and left on one
hand and scientific, showpoint and fixed on the other. Those two
groups can be combiened with each other, e.g. left and scientific
(= 6) is as far possible as right and fixed (= 17).
In addition to the member functions required by CNCL, `CNFormFloat'
provides:
`double get_value();'
`double value();'
`char get_fill();'
`char fill();'
`formats get_format();'
`formats format();'
`int get_width();'
`int width();'
`int get_precision();'
`int precision();'
Returns value, fill character, format style, width or precision of
the current CNFormFloat.
`void set_value(double x);'
`void value(double x);'
`void set_fill(char f);'
`void fill(char f);'
`void set_format(formats f);'
`format(formats f);'
`void set_width(int w);'
`void width(int w);'
`void set_precision(int pr);'
`void precision(int pr);'
Changes the current CNFormFloat by its value, fill character,
format style, width or precision.
File: cncl.info, Node: CNInt, Next: CNDouble, Prev: CNFormFloat, Up: Misc
CNInt -- Integers derived from CNObject
=======================================
SYNOPSIS
--------
`#include <CNCL/Int.h>'
TYPE
----
`CN_INT'
* Menu:
BASE CLASSES
------------
* CNObject:: Base class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNDouble:: Doubles derived from CNObject
DESCRIPTION
-----------
This class provides a long int value derived from CNObject. Such it
combines the behavior of the builtin type long int with the possibility
to use this type with generic containers (like CNDLList) or as
parameters to CNEvents and SDLSignals.
Note: CNInt consumes much more memory than an ordinary long int.
Therefore it isn't a good idea to create large arrays of CNInts when
one doesn't need its special capabilities.
Constructors:
`CNInt(long n=0);'
`CNInt(CNParam *param);'
Initializes the `Int' with the value n (default = 0).
In addition to the member functions required by CNCL, `CNInt' provides:
`operator long()'
Conversion of CNInt to ordinary long. This allows the use of
`CNInt' in calculations.
Note: to explicitly convert a CNInt identifier to a double (or
else) write double(long(identifier)). Implicit conversion however
works well without casting to long first.
`long operator ++()'
`long operator ++(int)'
Prefix and postfix version of increment.
`long operator --()'
`long operator --(int)'
Prefix and postfix version of decrement.
`long operator -()'
`long operator +()'
Unary minus and plus operator.
`long operator +=(long n)'
`long operator -=(long n)'
`long operator *=(long n)'
`long operator /=(long n)'
`long operator %=(long n)'
Arithmetic operators where a `CNInt' is on the left and on the
right side of an equation.
`long operator ^=(long n)'
`long operator |=(long n)'
`long operator &=(long n)'
`long operator !=(long n)'
Logical operators where a `CNInt' is on the left and on the right
side of an equation.
`long operator <<=(long n)'
`long operator >>=(long n)'
Left and right shifts of a `CNInt'.
Note: unary * and & operators aren't overloaded.
File: cncl.info, Node: CNDouble, Next: CNGetOpt, Prev: CNInt, Up: Misc
CNDouble -- Doubles derived from CNObject
=========================================
SYNOPSIS
--------
`#include <CNCL/Double.h>'
TYPE
----
`CN_DOUBLE'
* Menu:
BASE CLASSES
------------
* CNObject:: Base class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNInt:: Integers derived from CNObject
DESCRIPTION
-----------
This class provides a double value derived from CNObject. Such it
combines the behavior of the builtin type double with the possibility
to use this type with generic containers (like CNDLList) or as
parameters to CNEvents and SDLSignals.
Note: CNDouble consumes much more memory than an ordinary double.
Therfore it isn't a good idea to create large arrays of CNDoubles when
one doesn't need its special capabilities.
Constructors:
`CNDouble(double n=0.0);'
`CNDouble(CNParam *param);'
Initializes the `Double' with the value n (default = 0.0).
In addition to the member functions required by CNCL, `CNDouble'
provides:
`operator double()'
Conversion of CNDouble to ordinary double. This allows the use of
`CNDouble' in calculations.
Note: to explicitly convert a CNDouble identifier to an ordinary
long (or else) write long(double(identifier)). Implicit conversion
however works well without casting to double first.
`double operator -()'
`double operator +()'
Unary minus and plus operator.
`double operator +=(double n)'
`double operator -=(double n)'
`double operator *=(double n)'
`double operator /=(double n)'
Arithmetic operators where a `CNDouble' is on the left and on the
right side of an equation.
Note: unary * and & operators aren't overloaded.
File: cncl.info, Node: CNGetOpt, Next: CNRef, Prev: CNDouble, Up: Misc
CNGetOpt -- Interface to GNU getopt()
=====================================
SYNOPSIS
--------
`#include <CNCL/GetOpt.h>'
TYPE
----
`CN_GETOPT'
* Menu:
BASE CLASSES
------------
* CNObject:: Base class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
DESCRIPTION
-----------
This class manages the interface to the GNU getopt() functionality.
As an example for its use please see the file `tGetOpt.c' at the
directory `CNCL/lib/misc/test'.
Constructors:
`CNGetOpt();'
`CNGetOpt(CNParam *);'
`CNGetOpt(int argc, char **argv, char *copts=NIL);'
In addition to the member functions required by CNCL, `CNGetOpt'
provides:
`enum ParamType { NOPARAM=0, WPARAM=1, OPTPARAM=2 };'
`struct option { char *name; int has_arg; int *flag; int val; };'
Describe the long-named options requested by the application. The
LONG_OPTIONS argument to getopt_long or getopt_long_only is a
vector of `struct option' terminated by an element containing a
name which is zero.
`has_arg' is NOPARAM (0) if the option does not take an argument,
WPARAM (1) if the option requires an argument, or OPTPARAM (2) if
the option takes an optional argument.
If `flag' is not NULL, it points to a variable that is set to the
value given in `val' when the option is found, but left unchanged
if the option is not found.
To have a long-named option do something other than set an `int'
to a compiled-in constant, such as set a value from `optarg', set
`flag' to zero and `val' to a nonzero value (the equivalent
single-letter option character, if there is one). For long options
that have a zero `flag', `GetOpt' returns the contents of `val'.
`void set_args(int argc, char **argv);'
Set the `argc' and `argv' options.
`void set_char_options(char *copts);'
Set the single character option.
`void set_long_options(option *lopts);'
Set the long options array.
`void add_long_option (char *lopt, ParamType pt, char copt);'
Adds one long option to the current array (up to a total size of 32
elements). An example for one array entry could be:
{ "help", 0, 0, 'h'}, /* Help */
`int getopt();'
`int getopt(int argc, char *const *argv, const char *optstring);'
`int operator() ();'
Return the (short) getopt() value.
`int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options,'
`int *opt_index);'
Handles both short and long options.
`int getopt_long_only(int argc, char *const *argv, const char *options, const struct option *long_options,'
`int *opt_index);'
Handles only long options.
`char *optarg();'
`double optarg_double();'
`int optarg_int()'
`int optind();'
`int optopt();'
`void opterr(int err);'
These functions return the internal argument, index, unrecognized
option character or error value. These values are taken from the
original getopt.[h,c] files.
File: cncl.info, Node: CNRef, Next: CNRefObj, Prev: CNGetOpt, Up: Misc
CNRef -- Base class for classes with reference counting
=======================================================
SYNOPSIS
--------
`#include <CNCL/Ref.h>'
TYPE
----
* Menu:
BASE CLASSES
------------
None
DERIVED CLASSES
---------------
* CNRefObj:: CNObject with reference counting
* CNRefNamed:: CNNamed with reference counting
RELATED CLASSES
---------------
* CNPtr:: Intelligent pointer to CNRefObjs
DESCRIPTION
-----------
This class is the base class for classes with reference counting.
Note: `CNRef' is outside of CNCL's inheritance tree and is always used
as a further base class of its children, which are also derived from
`CNObject'.
With the help of reference counting you can track all references to
instances of `CNObject'.
See *note CNPtr::. and the file `tRef.c' in directory
`CNCL/lib/misc/test' for examples.
Constructors:
`CNRef();'
Initially the reference counter is set to zero.
`CNRef' provides:
`void ref();'
Increase the reference counter by one.
`void deref();'
Decrease the reference counter by one. If the reference counter
already was equal to zero, CNCL aborts with an error message. If
the decreased reference counter equals to zero, then the object of
this class deletes itself from memory, i.e. `delete this;'! In
this case you cannot access this object any longer.
`unsigned long get_count() const;'
Returns the number of references.
`static void set_debug(bool r, bool = FALSE);'
If `r' is set to `TRUE', all calls to `ref()' and `deref()' are
logged and a respective message is output to `cerr'. The second
parameter has no funcionality, yet.
File: cncl.info, Node: CNRefObj, Next: CNRefNamed, Prev: CNRef, Up: Misc
CNRefObj -- CNObject with reference counting
============================================
SYNOPSIS
--------
`#include <CNCL/RefObj.h>'
TYPE
----
`CN_REFOBJ'
* Menu:
BASE CLASSES
------------
* CNObject:: First base class
* CNRef:: Second base class
DERIVED CLASSES
---------------
None
RELATED CLASSES
---------------
* CNRefNamed:: CNNamed with reference counting
* CNPtr:: Intelligent pointer to CNRefObjs
DESCRIPTION
-----------
This class provides a common base for `CNObject's, all references to
which should be kept track of by its second base class `CNRef'.
Constructors:
`CNRefObj();'
In addition to the member functions required by CNCL, `CNRefObj'
provides no further functions.
File: cncl.info, Node: CNRefNamed, Next: CNPtr, Prev: CNRefObj, Up: Misc
CNRefNamed -- CNNamed with reference counting
=============================================
SYNOPSIS
--------
`#include <CNCL/RefNamed.h>'
TYPE
----
`CN_REFNAMED'
* Menu:
BASE CLASSES
------------
* CNNamed:: First base class
* CNRef:: Second base class
DERIVED CLASSES
---------------
None
RELATED CLASSES
---------------
* CNRefObj:: CNObject with reference counting
* CNPtr:: Intelligent pointer to CNRefObjs
DESCRIPTION
-----------
This class provides a common base for `CNNamed's, all references to
which should be kept track of by its second base class `CNRef'.
Constructors:
`CNRefNamed();'
`CNRefNamed(CNStringR name);'
In addition to the member functions required by CNCL, `CNRefNamed'
provides no further functions.
File: cncl.info, Node: CNPtr, Next: EZD, Prev: CNRefNamed, Up: Misc
CNPtr -- Intelligent pointer to CNRefObjs
=========================================
SYNOPSIS
--------
`#include <CNCL/Ptr.h>'
TYPE
----
`CN_PTR'
* Menu:
BASE CLASSES
------------
* CNObject:: Base class
DERIVED CLASSES
---------------
None
RELATED CLASSES
---------------
* CNRef:: Base class for classes with reference counting
* CNRefObj:: CNObject with reference counting
* CNRefNamed:: CNNamed with reference counting
DESCRIPTION
-----------
This class provides an intelligent pointer to `CNRefObj's, i.e. if
you copy one `CNPtr' to another one, then the reference count of the
`CNRefObj' contained in the source `CNPtr' is increased automatically
and the reference count of the `CNRefObj' contained in the destination
`CNPtr' is decreased automatically. See example below.
Constructors:
`CNPtr();'
`CNPtr(CNParam *param);'
`CNPtr(CNRefObj *o);'
`CNPtr(const CNPtr &p);'
In addition to the member functions required by CNCL, `CNPtr' provides:
`CNPtr& operator =(const CNPtr& p)'
Intelligent assignment operator. Additionally to copying the
`CNRefObj' data member, the reference count of the `CNRefObj' data
member contained in the source `CNPtr' is increased automatically
and the reference count of the `CNRefObj' data member contained in
the destination `CNPtr' is decreased automatically.
`CNRefObj *operator ->() const'
`CNRefObj *get_object() const'
Returns the `CNRefObj' data member.
Example:
CNRefObj *source_obj, *dest_obj;
CNPtr *source, *dest;
source_obj = new CNRefObj;
source_obj->ref();
source = new CNPtr(source_obj);
dest_obj = new CNRefObj;
dest_obj->ref();
dest = new CNPtr(dest_obj);
// ref counts
// source_obj : 1
// dest_obj : 1
// copy contents of source to dest
// implicitly increase counter of source_obj
// implicitly decrease counter of dest_obj and delete it
*dest = *source;
// ref counts
// source_obj : 2
// dest_obj : 0 (deleted)
// implicitly decrease counter of source_obj
delete source;
// implicitly decrease counter of source_obj and delete it
delete dest;
File: cncl.info, Node: Unix, Next: Misc, Prev: Object Management, Up: Top
Unix Classes
************
The classes described here provide an interface to the UNIX operating
system. Thus they will only work on machines where UNIX or compareable
systems like LINUX are installed. E.g., You won't be able to use them
in a DOS environment.
Additional information about the different Unix systam calls see the
man pages and your manual.
* Menu:
Unix
----
* CNPipe:: Unix Pipe
* CNSelect:: Class Interface to Select(2) System Call
File: cncl.info, Node: CNPipe, Next: CNSelect, Prev: CNManager, Up: Unix
CNPipe -- Unix Pipe
===================
SYNOPSIS
--------
`#include <CNCL/Pipe.h>'
TYPE
----
`CN_PIPE'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
DESCRIPTION
-----------
`CNPipe' creates and manages Unix I/O pipes between two programs,
thus that two cooperating processes can transfer data.
Constructors:
`CNPipe();'
`CNPipe(CNParam *param);'
`CNPipe(const CNString& prog);'
Initializing the pipe. If the program name `prog' is set, the pipe
will be opened immediately. Otherwise the open() command has to be
used when needed. The destructor closes the pipe if it was not
closed before.
In addition to the member functions required by CNCL, `CNPipe' provides:
`int open(const CNString& prog);'
Opens the pipe to the program. If the pipe already exists, the old
pipe will be closed before opening the new one. The returned
integer value indicates the success of the opening process. If
successful 0 is returned, otherwise an error message is shown and
-1 is returned.
`int close();'
Closes an existing pipe. If an error occurs, -1 is returned,
otherwise a 0.
`ostream & out();'
`istream & in ();'
Returns the input/output stream.
`int fd_in();'
`int fd_out();'
Returns the I/O pipe file descriptors.
`int get_pid();'
Returns the program's PID.
File: cncl.info, Node: CNSelect, Next: CNCoord, Prev: CNPipe, Up: Unix
CNSelect -- Class Interface to Select(2) System Call
====================================================
SYNOPSIS
--------
`#include <CNCL/Select.h>'
TYPE
----
`CN_SELECT'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
DESCRIPTION
-----------
`CNSelect' is the interface to Unix's "select(2)" system call for
synchronous I/O multiplexing. Select(2) (refer to Unix man pages, too)
examines the descriptor sets and detects if they are ready for reading,
writing, or having an exceptional status.
Constructors:
`CNSelect();'
`CNSelect(CNParam *param);'
`CNSelect(int fd);'
Initializes the three descriptor sets (one for the reading,
writing and exceptional descriptor set) to null sets. Optionally
the particular descriptor `fd' in the read set.
In addition to the member functions required by CNCL, `CNSelect'
provides:
`void add_read(int fd);'
`void del_read(int fd);'
`bool test_read(int fd);'
Adds/deletes/tests file descriptor `fd' to the read set.
`void add_write(int fd);'
`void del_write(int fd);'
`bool test_write(int fd);'
Adds/deletes/tests file descriptor `fd' to the write set.
`void add_except(int fd);'
`void del_except(int fd);'
`bool test_except(int fd);'
Adds/deletes/tests file descriptor `fd' to the except set.
`bool select();'
`bool select(long sec, long usec);'
Returns true if there are any ready descriptors in the three
descriptor sets. If the time values `sec' and `usec' for the
`timeout' are set, false is returned if the timer expires.
File: cncl.info, Node: EZD Interface, Next: Fuzzy, Prev: Misc, Up: Top
EZD Interface Classes
*********************
The following classes provide an interface to DEC's Easy Draw
application. Easy Draw is an application written in scheme which alows
easy drawing on the X 11 Window system. The CNCL simulation programs
communicate via UNIX pipes with Easy Draw.
These classes use Xcolors and Xfonts. A list of the colors you can find
at `/usr/global/lib/X11' in the file rgb.txt, for a list of fonts use
the command `xlsfonts'. Only the color 'clear' is added to allow
transparent objects in the drawing.
Additionally to the colors some stipple patterns are defined at EZD.
They are called s0, s1, ... , s16, where the number is representing the
amount of drawn pixels (in the defined color) in a square of 4-by-4.
However, this option is ignored when postscript files are written.
You can find additional information about ezd at the man pages.
* Menu:
EZD
---
* EZD:: Base Class for EZD Graphic Objects
* EZDObject:: Interface to EZD Object
* EZDDrawing:: Interface to EZD Drawings
* EZDPushButton:: Interface to EZD Push-Button
* EZDWindow:: Interface to EZD Windows
* EZDDiagWin:: Extra window with x-y diagram
* EZDTextWin:: EZD window for easy text display
* EZDDiag:: x-y diagram as an EZDObject
* EZDBlock:: Block with small rectangles for bit display
* EZDPopUp:: Interface to EZD popup menu
* EZDQueue:: Graphical Representation of a Queue
* EZDServer:: Graphical Representation of a Server
* EZDText:: EZD Object with Text
* EZDTimer:: Graphical Representation of a Timer
File: cncl.info, Node: EZD, Next: EZDObject, Prev: CNPtr, Up: EZD Interface
EZD -- Base Class for EZD Graphic Objects
=========================================
SYNOPSIS
--------
`#include <CNCL/EZD.h>'
TYPE
----
`CN_EZD'
* Menu:
BASE CLASSES
------------
* CNNamed:: CNObject with Name
DERIVED CLASSES
---------------
* EZDDrawing:: Interface to EZD Drawing
* EZDObject:: Interface to EZD Objects
* EZDPushButton:: Interface to EZD Push-Button
....
RELATED CLASSES
---------------
DESCRIPTION
-----------
`EZD' is the base class for EZD graphic objects. It manages the access
to EZD's I/O streams and provides the EZD drawing primitives. For
additional information about EZD, refer to the manual pages of EZD.
Constructors:
`EZD();'
`EZD(CNParam *param);'
`EZD(const CNStringR name);'
Initializes and opens the pipe to the EZD process.
In addition to the member functions required by CNCL, `EZD' provides:
`static ostream & out();'
Connects the stream from the program to the EZD process.
`static istream & in();'
Connects the stream from the EZD process to the program.
`static void draw_point(int x, int y, const CNStringR col)'
Draws a point at position (x,y) in color `col'.
`static void draw_line(int x1, int y1, int x2, int y2, const CNStringR col, int width = -1);'
`static void draw_dash_line(int x1, int y1, int x2, int y2, const CNStringR col, int width = -1);'
Draws a (dashed) line from point `(x1,y1)' to point `(x2,y2)' in
color `col' and `width' pixels wide. If `width' is <= 0, the
minimum of one pixel is used for it.
`static void draw_arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col, int width = -1);'
Draws an unfilled arc. `(x,y)' are the minimum coordinates of the
rectangle defining the arc. The arc's rectangle size is width `w'
by height `h'. The arc starts at `a1' degrees and spans `a2'
degrees - all angles are measured in the positive mathematical
sense, the positive x-axis is the reference axis. The drawing
color is `col' and the line width is `width'. If width <= 0 EZD's
default value (1 pixel) is used.
`static void draw_fill_arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col);'
Draws a filled arc (end-point to end-point of the arc). `(x,y)' are
the minimum coordinates of the rectangle defining the arc. The
arcs rectangle size is width w by heigth h. The arc starts at a1
degrees and spans a2 degrees - all angles measured in positive
mathematical sense, the positive x-axis is the reference axis. The
drawing color is `col'.
`static void draw_pie_arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col);'
Draws an arc (the arc is closed by drawing a line from each arc end
point to the center of the rectangle defining the arc). `(x,y)'
are the minimum coordinates of the rectangle defining the arc.
The arcs rectangle size is width w by heigth h. The arc starts at
a1 degrees and spans a2 degrees - all angles measured in positive
mathematical sense, the positive x-axis is the reference axis. The
drawing color is `col'.
`static void draw_rectangle(int x, int y, int w, int h, const CNStringR col, int width = -1);'
Draws an unfilled rectangle. `(x,y)' are the minimum coordinates.
The size is defined by its width w and its heigth h. The drawing
color is `col' and the line width is `width'. If width is <= 0
EZD's default value (1 pixel) is used.
`static void draw_fill_rectangle(int x, int y, int w, int h, const'
CNStringR col);
`static void draw_fill_rectangle(int x, int y, int w, int h, const CNStringR col, CNStringR stipple);'
Draws a filled rectangle. `(x,y)' are the minimum coordinates. The
size is defined by its width w and its heigth h. The drawing color
is `col'.
`static void draw_text(int x, int y, const CNStringR text, const CNStringR col, const CNStringR font);'
`static void draw_text(int x, int y, int w, int h, const CNStringR align, const CNStringR text, const CNStringR col, const CNStringR font);'
Writes `text' in the current drawing. `(x,y)' are the minimum
coordinates of the rectangle containing the text. `col' and `font'
describe color and font of the text. The optional width w, heigth
h and alignment information describe the size of this rectangle
and how the text has to be positioned in it. If the text does not
fit in, no text is displayed at all.
NOTE: Alternate functions with const char * args instead of
CNStringR are supplied for g++ 2.5.8, because g++ 2.5.8 generates
buggy code at least for calls to the 2nd draw_text() with string
constants "abc" args. Some of the temporary CNStrings are freed
twice.
`static void draw_bitmap(int x, int y, CNStringR filename, CNStringR color1 = "black", CNStringR color2= "");'
`static void draw_bitmap(int x, int y, int w, int h, CNStringR filename, CNStringR color1 = "black", CNStringR color2= "");'
Draws the bitmap for the file `filename' at position `x,y' in
width `w' and height `h'. The bits that are on are drawn in
`color1', those which are off in `color2'.
NOTE: The file must contain an X11 bitmap, a monochrome portable
bitmap (PBM, type P1), a gray scale portable bitmap (PGM, type
P2), or a color portable bitmap (PPM, type P3).
NOTE: Same problem with g++ 2.5.8 as described at the method
`draw_text()'.
`static void draw_now();'
Causes any buffered changes to be drawn immideately.
`static void draw_clear();'
Clears the current drawing.
`static void pause(int msec);'
Forces out any buffered changes and stops reading commands from
stdin until either `msec' milliseconds pass or some event action
issues a quit command.
`static CNString event();'
Reads event from pipe in EZD.
`static bool test_event();'
Returns true if there are ready descriptors in the I/O descriptor
sets (see also: CNSelect or man pages to "select(2)" system call)
`static void set_scale(const float xscale_x, const float xscale_y, const int xorigin_x, const int xorigin_y);'
`static int x2pix(const float x);'
`static int y2pix(const float y);'
In some applications it is necessary to map a drawing with a
cartesian coordinate system onto a window which uses pixels.
`set_scale' specifies the scale factor (default: scale (x,y) =
(1.0,1.0), origin (x,y) = (0,0)). `x2pix' and `y2pix' evaluate the
coordinate transformation for the given values `(x,y)' by the
formula `(value * scale + origin)', rounded to an integer.
`static void print_window(CNStringR winname, CNStringR dateiname);'
Prints the window named `winname' to disk. The file `dateiname' is
in postscript format.
`static void save_drawing();'
`static void restore_drawing();'
Saves/restores the current drawing.
File: cncl.info, Node: EZDObject, Next: EZDDrawing, Prev: EZD, Up: EZD Interface
EZDObject -- Interface to EZD Object
====================================
SYNOPSIS
--------
`#include <CNCL/EZDObject>'
TYPE
----
`CN_EZDOBJECT'
* Menu:
BASE CLASSES
------------
* EZD:: Base Class for EZD Graphic Objects
DERIVED CLASSES
---------------
* EZDQueue:: Graphical Representation of a Queue
* EZDServer:: Graphical Representation of a Server
* EZDText:: EZD Object with Text
* EZDTimer:: Graphical Representation of a Timer
RELATED CLASSES
---------------
* EZDDrawing:: Interface to EZD Drawings
* EZDPushButton:: Interface to EZD Push-Button
* EZDWindow:: Interface to EZD Windows
DESCRIPTION
-----------
`EZDObject' provides an interface to the objects of Easy Draw. Thus
the drawings in all derived classes are handled as objects.
Constructors:
`EZDObject();'
`EZDObject(CNParam *param);'
`EZDObject(int x, int y);'
`EZDObject(const CNStringR name, int x, int y);'
Initializes the EZD-object with either name "obj" or `&name'.
`(x,y)' are the object's minimum coordinates.
Public accessible members:
`int x();'
Returns the `EZDObject''s x coordinate.
`int x(int vx);'
Returns the `EZDObject''s old x coordinate and changes it to `vx'.
`int y();'
Returns the `EZDObject''s y coordinate.
`int y(int vy);'
Returns the `EZDObject''s old y coordinate and changes it to `vy'.
In addition to the member functions required by CNCL, `EZDObject'
provides:
`void start();'
`void start(const CNStringR object_name);'
`void end();'
"Start/End object drawing" command. All drawing commands between
`start()' and `end()' draw the named object in the current
drawing. If the named object already exists in the current
drawing, it is replaced by the new one. If no drawing commands are
specified between `start()' and `end()', the drawing still exists,
but with no graphical representation.
`void delete_obj(const CNStringR draw_name = "draw");'
Deletes the named drawing in the current object.
`int get_lastxb(void);'
`int get_lastyb(void);'
`int get_lastxe(void);'
`int get_lastye(void);'
Returns the object's last positions.
`void point(int x, int y, const CNStringR col);'
`void line(int x1, int y1, int x2, int y2, const CNStringR col, int width = -1);'
`void arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col, int width = -1);'
`void fill_arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col);'
`void pie_arc(int x, int y, int w, int h, int a1, int a2, const CNStringR col);'
`void rectangle(int x, int y, int w, int h, const CNStringR col, int width = -1);'
`void fill_rectangle(int x, int y, int w, int h, const CNStringR col);'
`void text(int x, int y, const CNStringR text, const CNStringR col, const CNStringR font);'
`void text(int x, int y, int w, int h, CNString align, CNStringR text, CNStringR col, CNStringR font);'
`void bitmap(int x, int y, int w, int h, CNStringR filename, CNStringR color1 = "black", CNStringR color2 = "");'
`void bitmap(int x, int y, CNStringR filename, CNStringR color1 = "black", CNStringR color2 = "");'
Basic drawing commands ( exact description see section `EZD' or
EZD's man pages). The command's `(x,y)' coordinates determine the
position in the object. For the position in the current drawing the
object's coordinates `(ox,oy)' are added automatically.
`virtual void redraw();'
Virtual redraw function ( has to be implemented by derived objects
).
File: cncl.info, Node: EZDDrawing, Next: EZDPushButton, Prev: EZDObject, Up: EZD Interface
EZDDrawing -- Interface to EZD Drawings
=======================================
SYNOPSIS
--------
`#include <CNCL/EZDDrawing.h>'
TYPE
----
`CN_EZDDRAWING'
* Menu:
BASE CLASSES
------------
* EZD:: Base Class for EZD Graphic Objects
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* EZDObject:: Interface to EZD Object
* EZDPushButton:: Interface to EZD Push-Button
* EZDWindow:: Interface to EZD Windows
DESCRIPTION
-----------
`EZDDrawing'
Constructors:
`EZDDrawing();'
`EZDDrawing(CNParam *param);'
`EZDDrawing(const CNString &name);'
`EZDDrawing(const CNString &name, const int x, const int y, const int w, const int h);'
Sets this drawing to the current drawing. Its name is either
`name' or (by default) "draw".
Additional functions :
`void set();'
sets this drawing to the current drawing.
File: cncl.info, Node: EZDPushButton, Next: EZDWindow, Prev: EZDDrawing, Up: EZD Interface
EZDPushButton -- Interface to EZD Push-Button
=============================================
SYNOPSIS
--------
`#include <CNCL/EZDPushButton>'
TYPE
----
`CN_EZDPUSHBUTTON'
* Menu:
BASE CLASSES
------------
* EZD:: Base Class for EZD Graphic Objects
DERIVED CLASSES
---------------
RELATED CLASSES
----------------
* EZDObject:: Interface to EZD Objects
* EZDDrawing:: Interface to EZD Drawing
* EZDWindow:: Interface to EZD Window
DESCRIPTION
-----------
`EZDPushButton' defines a push-button in the current drawing. The
button is defined by it's minimum `(x,y)' coordinates, it's width `w'
by heigth `h' rectangle size and it's `CNNamed' object name. The
default values are x = y = 0, w = 50, h = 20, name = "button".The
button is drawn as a filled white rectangle with a black border. The
button's `text' is written in black characters in the center of the
button.
When the mouse enters a button with an action, the border is thickened.
When the mouse button 1 is pressed, the button colors are reversed.
Releasing mouse button 1 the push-button's `action' is taken and it is
drawn as before.
NOTE: If you leave the button's area with your mouse during
pressing/releasing the mouse button no `action' will be taken.
Constructors:
`EZDPushButton();'
`EZDPushButton(CNParam *param);'
`EZDPushButton(const CNString &name, int vx, int vy, int vw, int vh, const CNString &vtext);'
`EZDPushButton(const CNString &name, int vx, int vy, int vw, int vh, const CNString &vtext, const CNString &vaction);'
Initializes the push-button in the current drawing. `name' is the
object's name (default: "button"), `(vx, vy)' the minimum (x,y)
coordinates (default: (0,0)), `(vw, vh)' the button's width and
heigth (50,20), `vtext' the describing text in the current drawing
("button") and `vaction' the action taken when the button is
pressed ("log-event").
In addition to the member functions required by CNCL, `EZDPushButton'
provides:
`void set_text(const CNString &t);'
Sets the push-button's text to t.